/**
 * Created by qqqqqqq on 2017/3/12.
 */
function parseAvatar(t, e) {
    return t && e && "null" !== e ? $.strformat("http://pic.qiushibaike.com/system/avtnew/{0}/{1}/medium/{2}", parseInt(t / 1e4), t, e) : "http://static.qiushibaike.com/images/thumb/missing.png"
}
function initeScroll() {
    this.pageNo = 0, this.pageSize = 20, this.totalCount = -1, this.isLoading = !1, this.param = {}
}
function uploadImgPreview(t, e) {
    function i(t, e) {
        var t = t.files[0], i = new FileReader;
        i.readAsDataURL(t), i.onload = function (t) {
            e.src = this.result
        }
    }

    function n(t) {
        var e = $("#" + t.getAttribute("id"));
        e.val(null), e.after(e.clone()), e.remove()
    }

    $("input[name='avatar_type']").val("local");
    var o = $(".user-photo")[0];
    $(".up-photo span").html(t.value);
    var a = t.value.substring(t.value.lastIndexOf(".") + 1).toLowerCase();
    if ("png" != a && "jpg" != a && "jpeg" != a && "gif" != a && "bmp" != a)return n(t), alert("只能上传png,jpg,jpeg,gif,bmp格式的图片!");
    if (document.all)try {
        t.select();
        var r = document.selection.createRange().text, s = /msie 6/i.test(navigator.userAgent);
        s ? o.src = r : (o.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod='scale',src='" + r + "')", o.src = "")
    } catch (l) {
        if (!e)return !1;
        o.src = e
    } else i(t, o)
}
function post() {
    function t(t) {
        return $(".error-info").html(t), !1
    }

    if (!isRuning) {
        var e = $.trim($("#user-name").val());
        if (!e || "用户名" == e)return t("请输入您的用户名。");
        if (e.length < 4)return t("用户名至少需要输入4个字符。");
        if (e.length > 16)return t("用户名不能大于16个字符。");
        opUploadStart(), $("#upload-form").submit()
    }
}
function opUploadStart() {
    isRuning = !0, $(".user-register").html("正在提交..")
}
function opUploadEnd() {
    isRuning = !1, $(".user-register").html("完成注册")
}
function uploadCallback(t) {
    return opUploadEnd(), 0 != t.err ? void $(".error-info").html(t.err_msg) : ($.setCookie("_qqq_auth_token", t.token, {domain: ".qiushibaike.com"}), void(window.location.href = "http://" + window.location.host + "/?token=" + t.token))
}
Array.indexOf || (Array.prototype.indexOf = function (t) {
    for (var e = 0; e < this.length; e++)if (this[e] == t)return e;
    return -1
});
var activeFloatAd = function (t, e) {
    var i = e ? e : "top", n = scrollMonitor.create(t), o = $("#footer");
    if (o.length)var a = scrollMonitor.create(o, {top: "top" == i ? parseInt(t.css("height"), 10) : 0}); else var a = scrollMonitor.create($(".foot"), {top: "top" == i ? parseInt(t.css("height"), 10) : 0});
    var r = "fixed-ads sl-fixed sl-fixed-" + i + " fixed-ads-offset-" + i, s = "absolute-ads";
    return n.lock(), "top" == i ? (n.stateChange(function () {
        t.hasClass(s) && t.removeClass(s), t.toggleClass(r, this.isAboveViewport)
    }), n.exitViewport(function () {
        n.isAboveViewport && t.hasClass("fixed-ads") === !1 && t.addClass(r)
    }), a.fullyEnterViewport(function () {
        this.isAboveViewport && t.removeClass(r).addClass(s)
    }), a.partiallyExitViewport(function () {
        this.isBelowViewport && t.removeClass(s).addClass(r)
    })) : (n.stateChange(function () {
        t.hasClass(s) || t.toggleClass(r, !this.isFullyInViewport && this.isAboveViewport)
    }), n.partiallyExitViewport(function () {
        !n.isAboveViewport || n.isFullyInViewport || t.hasClass("fixed-ads") !== !1 || t.hasClass(s) || t.addClass(r)
    }), a.enterViewport(function () {
        t.removeClass(r).addClass(s)
    }), a.exitViewport(function () {
        this.isBelowViewport && t.removeClass(s).addClass(r)
    })), {ad: n, footer: a}
};
setTimeout(function () {
    var t = $(".main .content-block .col1"), e = $("#sidebar");
    t.height() > e.height() && (window._floatAd = activeFloatAd($("#sidebar"), "bottom"))
}, 500);
var activeFloatComments = function (t, e) {
    var i = function () {
        var i = "fixed-comments sl-fixed sl-fixed-bottom", n = scrollMonitor.create(t, -52), o = scrollMonitor.create(e, -200);
        return o.enterViewport(function () {
            o.isBelowViewport && t.addClass(i)
        }), o.exitViewport(function () {
            t.removeClass(i)
        }), n.lock(), n.enterViewport(function () {
            t.removeClass(i)
        }), n.exitViewport(function () {
            (n.isBelowViewport || o.isInViewport) && t.addClass(i)
        }), {
            update: function () {
                n.unlock(), n.recalculateLocation(), n.lock()
            }
        }
    };
    return i(t, e)
}, app = window.app || {};
$.readCookie = function (t) {
    var e = document.cookie.match("\\b" + t + "=([^;]*)\\b");
    return e ? e[1] : null
}, app.sign = {}, app.sign.submit = function (t) {
    var e = $(t || "#login-form");
    if (!e.length)return !1;
    e.find("button[type=submit]").click(function (t) {
        return $(this.form).submit(), t.preventDefault(), !1
    });
    var i = null;
    e.find("form").find('[name="password"]').one("focus change input", function () {
        i || (i = new Date)
    }), e.find("form").submit(function (t) {
        t.preventDefault();
        var e = $("#login-form"), n = -1;
        if (i) {
            var o = new Date;
            n = o.getTime() - i.getTime()
        }
        $('<input type="hidden" name="duration">').val("" + n).appendTo(this);
        var a = $.readCookie("_xsrf");
        return $.post("/new4/session", $(this).serialize() + "&_xsrf=" + a, function (t) {
            return t.err > 0 ? (e.removeClass("animated shake fadeInUp"), setTimeout(function () {
                e.addClass("animated shake")
            }, 10), $("#signin-error").text(t.err_msg).show()) : (e.removeClass("animated fadeInUp"), void setTimeout(function () {
                e.addClass("animated fadeOutUp"), setTimeout(function () {
                    app.sign.load(t), $("#login-form").trigger("close"), $(document).trigger("after_logged_in")
                }, 400)
            }, 10))
        }, "json"), !1
    })
}, app.sign.load = function (t) {
    return t && t.user ? (app.user = t.user, app.ui.signin(app.user), void VoteHistory.updateArticleStates()) : app.ui.signin({})
}, app.sign.trust = function () {
    function t(t, e) {
        e = e ? e : window.location.href;
        var i = new RegExp("(\\?|&)" + t + "=([^&?]*)", "i"), n = e.match(i);
        return n ? n[2] : null
    }

    var e = app.sign, i = {}, n = {}, o = (new Date).getTime(), a = window.location.href;
    if (i.id = $.readCookie("_qqq_trust.id"), i.user = $.readCookie("_qqq_user"), n.token = $.readCookie("_qqq_auth_token"), n.qqq = $.readCookie("_qqq_session"), a.indexOf("token") > -1 && $.setCookie) {
        var r = t("token", a), s = $.readCookie("_qqq_session");
        s && $.delCookie("_qqq_session"), $.setCookie("_qqq_auth_token", r, {domain: ".qiushibaike.com"})
    }
    if (i.id && i.user) {
        var l = {};
        return l.unread_messages_count = 0, l.user = {}, l.user.login = _Base64.decode(i.user), l.user.id = parseInt(i.id, 10), e.load(l), l
    }
    return n.token || n.qqq ? $.getJSON("/new4/session?" + o, e.load) : (e.load({}), !1)
}, app.sign.init = function () {
    app.sign.trust(), app.sign.submit()
};
var app = window.app || {};
app.ui = {}, app.ui.avatar = function (t, e) {
    var i = "http://www.qiushibaike.com/static/images/medium/missing.png";
    if (!t || "None" == t)return i;
    if (!e)return i;
    var n = parseInt(parseInt(e / 1e4));
    return "http://pic.qiushibaike.com/system/avtnew/" + n + "/" + e + "/medium/" + t
}, app.ui.signpopup = function () {
    var t = $("#login-form");
    return !!t.length && (t.lightbox_me({centered: !0}), t.removeClass("animated shake"), void t.addClass("animated fadeInUp"))
}, app.ui.signin = function (t) {
    var e = "object" == typeof t && t.login;
    if (e) {
        var i = $("#global-user .username span.nickname");
        i.length ? (i.text(t.login), $("#global-user .login").prepend('<a target="_blank" href="/my" rel="external nofollow"><img   class="global-avatar" src="' + app.ui.avatar(t.avatar_file_name, t.id) + '" ></a>')) : $(".login .username").text(t.login).parent().prepend('<a target="_blank" href="/my" rel="external nofollow"><img  class="global-avatar" src="' + app.ui.avatar(t.avatar_file_name, t.id) + '"></a>'), $(".login").show(), $(".logout").hide()
    } else $(".logout").show(), $(".login").hide();
    return !1
}, app.ui.commentmeta = function (t) {
    var e = $(t);
    return !!e.length && void e.live("mouseenter", function () {
            app.user && $(this).children(".report").css("display", "inline")
        }).live("mouseleave", function () {
            return "已举报" != $(this).children(".report").find("a").text() && void $(this).children(".report").css("display", "none")
        })
}, app.ui.closelightbox = function (t) {
    var e = $(t);
    return !!e.length && void e.live("click", function () {
            $("#login-form").trigger("close")
        })
}, app.ui.redirect = function (t) {
    var e = $(t);
    return !!e.length && void e.click(function (t) {
            function e(t, e) {
                document.cookie = t + "=" + escape(e) + "; domain=.qiushibaike.com; path=/"
            }

            var i = $(this).attr("data-go");
            if ("window" === i && (i = window.location.href), app.user && i)return window.location.href = i;
            if (app.user)return !0;
            app.ui.signpopup();
            var n = window.location.href, o = document.domain, a = n.split(o)[1];
            return e("callback_url", a), !i || void $(document).bind("after_logged_in", function () {
                window.location.href = i
            })
        })
};
var app = window.app || {};
$.readCookie = function (t) {
    var e = document.cookie.match("\\b" + t + "=([^;]*)\\b");
    return e ? e[1] : null
}, app.comment = {}, app.comment.submit = function () {
    var t = $(this), e = this.form, i = $.trim($(e).find("#comment-area").val());
    if ("" == i)return !1;
    var n = $.readCookie("_xsrf");
    return $.post(e.action, $(e).serialize() + "&_xsrf=" + n, function (i) {
        t.text("评论"), $(e).find("#comment-area").val("");
        var n = $("#r" + $(e).attr("data-article_id")).find(".comment-tips");
        if (!n.length)return !1;
        n.before(i);
        var o = $(i).attr("id"), a = $("#" + o);
        $("html, body").animate({scrollTop: $("#comments-num").position().top + $("#comments-num").parent().height()}), a.css({"background-color": "#fffbc9"}), setTimeout(function () {
            a.animate({backgroundColor: "#fff"}, 3e3)
        }, 800)
    }), t.text("发表中"), !1
}, app.comment.hotkey = function () {
    $(document).keypress(function (t) {
        if (t.ctrlKey && 10 === t.which && 13 === t.which && t.target.form) {
            var e = $(t.target.form).find("#comment_submit");
            app.comment.submit.call(e[0])
        }
    })
}, app.comment.bind = function (t) {
    var e = $(t);
    return !!e.length && (e.live("click", app.comment.submit), void app.comment.hotkey())
}, app.comment.init = function (t) {
    app.comment.bind(t || "#comment_submit"), $("#comment-area").css("overflow", "hidden").autogrow()
}, function (t) {
    t.fn.autoTextarea = function (e) {
        var i = {maxHeight: null, minHeight: t(this).height()}, n = t.extend({}, i, e);
        return t(this).each(function () {
            t(this).bind("paste cut keydown keyup focus blur change", function () {
                var t, e = this.style;
                this.style.height = n.minHeight + "px", this.scrollHeight > n.minHeight && (n.maxHeight && this.scrollHeight > n.maxHeight ? (t = n.maxHeight, e.overflowY = "scroll") : (t = this.scrollHeight, e.overflowY = "hidden"), e.height = t + "px")
            })
        })
    }
}(jQuery), $.strformat = function () {
    var t, e = /\{([\d\w\.]+)\}/g, i = Array.prototype.slice.call(arguments);
    return str = i.shift() + "", 1 == i.length && "object" == typeof i[0] && (i = i[0]), e.lastIndex = 0, str.replace(e, function (e, n) {
        return t = i[n], void 0 === t ? e : t
    })
}, initeScroll.prototype = {
    constructor: initeScroll, reset: function () {
        this.pageNo = 0, this.pageSize = 20, this.totalCount = -1
    }, isScrollBottom: function () {
        _floatComments.update();
        var t = this;
        $(window).scroll(function () {
            var e = $(document).height(), i = $(window).scrollTop(), n = $(window).height();
            e - i - n < 1020 && t.loadMore()
        })
    }, loadMore: function (t) {
        _floatComments.update();
        var e = this;
        e.canBeLoad() && (e.pageNo++, e.isLoading = !0, e.loadAndRender())
    }, getUrlParam: function (t, e) {
        e = e ? e : window.location.href;
        var i = new RegExp("(\\?|&)" + t + "=([^&?]*)", "i"), n = e.match(i);
        return n ? n[2] : null
    }, loadAndRender: function () {
        _floatComments.update();
        var t = (window.location.href, $("#comment_article_id").val()), e = (this.getUrlParam("list"), this.getUrlParam("s"), $("#r" + t).find(".comment-tips")), i = this;
        e.show(), _floatComments.update(), $.ajax({
            url: "/commentpage/" + t + "?list=" + i.getUrlParam("list") + "&s=" + i.getUrlParam("s") + "&page=" + i.pageNo,
            cache: !1,
            dataType: "json",
            success: function (t) {
                i.isLoading = !1, i.totalCount = t.comments.total - 200, i.pageSize = t.comments.count > i.pageSize ? t.comments.count : i.pageSize;
                var n = template.compile($("#comments-render").html());
                template.helper("parseAvatar", parseAvatar), template.helper("content", function (t) {
                    var t = template.utils.$escape(t);
                    return t.replace(/(\\n)/g, "<br>")
                });
                var o = n(t);
                e.hide().before(o), _floatComments.update()
            }
        })
    }, canBeLoad: function () {
        return !this.isLoading && this.isAllLoad()
    }, isAllLoad: function () {
        var t = this.pageNo + 1, e = this.totalCount == -1 || t <= Math.ceil(this.totalCount / this.pageSize);
        return e
    }, loadComplete: function () {
        this.isAllLoad()
    }
}, $(function () {
    if ($(".isCommentPage").length > 0) {
        var t = $(".content-block #comment-wrap"), e = $(".content-block .comments > div");
        window._floatComments = activeFloatComments(t, e);
        var i = $("#r" + $("#comment_article_id").val());
        if (i.find(".floor-200").length <= 0)return i.find(".comment-tips").hide();
        var n = new initeScroll;
        n.isScrollBottom()
    }
});
var hidevotelink = function (t, e, i, n) {
    var o = {}, a = {};
    o.up = $("#vote-up-" + t).find("a"), o.down = $("#vote-dn-" + t).find("a"), a.up = $("#up-" + t).find("span.number"), a.down = $("#dn-" + t).find("span.number");
    var r = o.up.parents(".stats-buttons").siblings(".stats"), s = r.find(".stats-vote i.number"), l = "undefined" == typeof i ? parseInt(a.up.text()) : i, c = "undefined" == typeof n ? parseInt(a.down.text()) : n;
    a.up.text(l), a.down.text(c), s.text(l + c), "up" == e ? (s.css("font-weight", "bold"), o.up.addClass("voted")) : o.down.addClass("voted"), o.up.addClass("disable"), o.down.addClass("disable")
}, VoteHistory = {
    _Historys: null, _IsValid: null, voteState: function (t, e) {
        return this.isValid() ? null == e ? this._Historys[t] : (this._Historys[t] = e, void this.saveHistory()) : 0
    }, isValid: function () {
        return null == this._IsValid && (this._IsValid = !!window.localStorage), this._IsValid
    }, readHistory: function () {
        this._Historys = window.localStorage.getItem("vote_history"), this._Historys = JSON.parse(this._Historys), null == this._Historys && (this._Historys = {})
    }, saveHistory: function () {
        if (null != this._Historys) {
            var t = 500, e = function (t) {
                var e = [];
                for (var i in t)e.push(i);
                return e
            }, n = e(this._Historys);
            if (n.length > t) {
                var o = n.length - t;
                for (i = 0; i < o; i++)delete this._Historys[n[i]]
            }
            var a = JSON.stringify(this._Historys);
            window.localStorage.setItem("vote_history", a)
        }
    }, _init: function () {
        this.isValid() && this.readHistory()
    }, updateArticleStates: function () {
        this.isValid() && (articles = [], $.each($("div[id^=qiushi_counts_]"), function () {
            articles.push(+this.id.replace("qiushi_counts_", ""))
        }), $.each(articles, function (t) {
            var e = articles[t], i = VoteHistory.voteState(e);
            if (void 0 != i) {
                var n = parseInt($("#up-" + e).find("span.number").text()), o = parseInt($("#dn-" + e).find("span.number").text());
                d = i > 0 ? "up" : "dn", i > 0 ? n++ : o--, hidevotelink(e, d, n, o)
            }
        }))
    }
}, voting = function t(e, i) {
    function n(t, e, i) {
        var n = i > 0 ? "+" : "-";
        return _Base64.encode(t + n + e)
    }

    function o(t, e) {
        document.cookie = t + "=" + escape(e) + "; domain=.qiushibaike.com; path=/"
    }

    if (!$("#up-" + e).hasClass("disable") && !$("#dn-" + e).hasClass("disable"))if (app.user) {
        var a = parseInt($("#up-" + e).find("span.number").text()), r = parseInt($("#dn-" + e).find("span.number").text()), s = i > 0 ? "up" : "dn";
        $.getJSON("http://www.qiushibaike.com/new3/vote/" + n(e, app.user.id, i)), i > 0 ? a++ : r--, hidevotelink(e, s, a, r), VoteHistory.voteState(e, i)
    } else {
        app.ui.signpopup();
        var l = window.location.href, c = document.domain, u = l.split(c)[1];
        o("callback_url", u), $(document).bind("after_logged_in", function () {
            t(e, i)
        })
    }
}, app = window.app || {};
app.user = null, $(document).ready(function () {
    function t() {
        $(".closeUserCenterLi").hide(), $(".openUserCenterLi").show(), $("#closeUserCenterTips").hide()
    }

    function e() {
        $(".closeUserCenterLi").show(), $(".openUserCenterLi").hide(), $("#closeUserCenterTips").show()
    }

    app.sign.init(), VoteHistory._init(), app.ui.closelightbox("#login-form a.close"), app.ui.commentmeta(".comment"), app.ui.redirect(".fn-signin-required"), app.comment.init("#comment_submit"), $("input[placeholder], textarea[placeholder]").placeholder(), $(".article .single-share").on("click", "a", function () {
        var t = $(this).parent().parent(), e = $(this).attr("data-type"), i = t.find(".content").text(), n = i.substring(0, 22) + " @糗事百科", o = "http://www.qiushibaike.com/article/" + t.attr("id").split("_")[2], a = t.find(".thumb img").attr("src") || "";
        "weibo" == e ? window.open("http://service.weibo.com/share/share.php?appkey=63372306&url=" + o + "&ralateUid=1850235592&title=" + i + "&pic=" + a) : "qq" == e ? window.open("http://connect.qq.com/widget/shareqq/index.html?url=" + o + "%0A+&title=" + n + "%0A+&summary=" + i + "%0A+&pics=" + a + "%0A+&site=糗事百科") : "qzone" == e && window.open("http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url=" + o + "&title=" + n + "&summary=" + i + "&pics=" + a + "&site=糗事百科")
    }), $(".article .single-share").on("mouseover", "a", function () {
        var t = $(this).parent().parent(), e = $(this).attr("data-type"), i = "http://www.qiushibaike.com/article/" + t.attr("id").split("_")[2];
        "wechat" == e && $(this).after("<div class='share-wechat-tips'><img src='http://s.jiathis.com/qrcode.php?url=" + i + "'>使用微信“扫一扫”，点击手机屏幕右上角“…”分享</div>")
    }), $(".article .single-share").on("mouseout", "a", function () {
        var t = $(this).attr("data-type");
        "wechat" == t && $(this).parent().find(".share-wechat-tips").remove()
    });
    var i = function () {
        function t() {
            var t = encodeURI(window.location.href), e = $("title").html() || $("title").attr("innerHTML");
            try {
                window.external.addFavorite(t, e);
                var i = $("#alert_coll_page");
                i.find(".alert_coll_text").html("已收藏本页面"), i.show()
            } catch (n) {
                try {
                    window.sidebar.addPanel(e, t, "");
                    var i = $("#alert_coll_page");
                    i.find(".alert_coll_text").html("已收藏本页面"), i.show()
                } catch (n) {
                    var i = $("#alert_coll_page");
                    i.find(".alert_coll_text").html("请使用Ctrl＋D进行收藏。"), i.show()
                }
            }
            try {
                _hmt.push(["_trackEvent", "web_article_collection", "chick"])
            } catch (n) {
                console.log(n)
            }
        }

        function e(t, e) {
            document.cookie = t + "=" + escape(e) + "; domain=.qiushibaike.com; path=/"
        }

        function i(t) {
            var e, i = new RegExp("(^| )" + t + "=([^;]*)(;|$)");
            return (e = document.cookie.match(i)) ? unescape(e[2]) : null
        }

        document.getElementById("single-next-link").onclick = function () {
            var t = parseInt(i("__cur_art_index"));
            if (null != t) {
                var n = 0;
                if (t < 9999)var n = t + 1;
                e("__cur_art_index", n)
            }
            try {
                _hmt.push(["_trackEvent", "web_article_content", "chick"])
            } catch (o) {
                console.log(o)
            }
            location.href = $("#articleNextLink").val()
        }, document.getElementById("single-next-link-button").onclick = function () {
            var t = parseInt(i("__cur_art_index"));
            if (null != t) {
                var n = 0;
                if (t < 9999)var n = t + 1;
                e("__cur_art_index", n)
            }
            try {
                _hmt.push(["_trackEvent", "web_article_next", "chick"])
            } catch (o) {
                console.log(o)
            }
            location.href = $("#articleNextLink").val()
        }, document.getElementById("single-pre-link").onclick = function () {
            var t = parseInt(i("__cur_art_index"));
            if (null != t) {
                var n = 9999;
                if (t > 0)var n = t - 1;
                e("__cur_art_index", n)
            }
            try {
                _hmt.push(["_trackEvent", "web_article_last", "chick"])
            } catch (o) {
                console.log(o)
            }
            location.href = $("#articlePreLink").val()
        }, document.getElementById("single-coll").onclick = function () {
            t()
        }, document.getElementById("alert_coll_btn").onclick = function () {
            var t = document.getElementById("alert_coll_page");
            t.style.display = "none"
        }
    };
    1 == $("#isArticle").val() && i();
    var n = $("#invisible").val() || null;
    if (null != n) {
        var o = function (t) {
            var e = document.cookie.match("\\b" + t + "=([^;]*)\\b");
            return e ? e[1] : null
        }, a = o("closeUserCenter");
        null == a ? 1 == n ? t() : e() : 1 == a ? t() : e(), $("#closeUserCenter").click(function () {
            var e = $.readCookie("_xsrf");
            $.ajax({
                url: "/my/invis",
                cache: !1,
                dataType: "json",
                data: {invisable: 1, _xsrf: e},
                type: "post",
                success: function (e) {
                    t();
                    var i = new Date;
                    i.setTime(i.getTime() + 6e5), document.cookie = "closeUserCenter=" + escape(1) + ";expires=" + i.toGMTString() + ";domain=.qiushibaike.com; path=/"
                },
                error: function () {
                    alert("请求服务器失败，请稍候再试")
                }
            })
        }), $("#openUserCenter").click(function () {
            var t = $.readCookie("_xsrf");
            $.ajax({
                url: "/my/invis",
                cache: !1,
                dataType: "json",
                data: {invisable: 0, _xsrf: t},
                type: "post",
                success: function (t) {
                    e();
                    var i = new Date;
                    i.setTime(i.getTime() + 6e5), document.cookie = "closeUserCenter=" + escape(0) + ";expires=" + i.toGMTString() + ";domain=.qiushibaike.com; path=/"
                },
                error: function () {
                    alert("请求服务器失败，请稍候再试")
                }
            })
        })
    }
});
var isRuning = !1;
!function (t) {
    var e = function (e) {
        return this.limit = e.limit || 250, this.textarea = t(e.textarea), this.submit = t(e.submit), !!this.textarea.length && (this.listen(), void this.bindSubmit())
    };
    e.prototype.bindSubmit = function () {
        var t = this.textarea, e = this.limit;
        this.submit.click(function (i) {
            return !(t.val().length > e)
        })
    }, e.prototype.createTip = function (t, e) {
        return ["<span style='color:" + e + ";'>", "<strong style='font-weight:bold;'>", t, "</strong>字", "</span>"].join("")
    }, e.prototype.listen = function () {
        var e = this.textarea, i = this.limit, n = this.submit, o = this.tip || e.siblings("#length"), a = this;
        return e.keyup(function (e) {
            var r = i - t(this).val().length;
            r >= 0 ? (n.hasClass("disabled") && n.removeClass("disabled"), o.html(a.createTip(r, "#0099FF"))) : (n.hasClass("disabled") || n.addClass("disabled"), o.html(a.createTip(r, "red")))
        }), this
    }, t.fn.checkLength = function (i) {
        new e({textarea: t(this), limit: i.limit, submit: i.submit})
    }
}(jQuery), function (t) {
    function e() {
        t(".video_holder").click(">div", function (t) {
            t.stopPropagation()
        }).css("cursor", "auto")
    }

    function i() {
        e()
    }

    t("#comment-area").checkLength({limit: 140, submit: "#comment_submit"}), t(document).ready(i)
}(jQuery);
var backupArticle = function (t) {
    var e = window.localStorage;
    if (e) {
        var i = e.getItem("article");
        null != i && i.length > 5 && ($("#qiushi_text").focus(), $("#qiushi_text").val(i)), setInterval(function () {
            var t = $("#qiushi_text").val();
            t && t.length > 5 ? e.setItem("article", t) : e.removeItem("article")
        }, t ? t : 5e3)
    }
};
$(document).ready(function () {
    backupArticle(), $("#qiushi_text").checkLength({limit: 260, submit: "#article_submit"})
});